package com.example.demo.dao;

import com.example.demo.bean.Question;
import com.example.demo.bean.Word;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @author Jim Chen
 * @date 2021-04-15
 */
@Mapper
@Repository
public interface QuestionDao {

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "question", column = "question"),
            @Result(property = "answer", column = "answer"),
            @Result(property = "optionA", column = "option_a"),
            @Result(property = "optionB", column = "option_b"),
            @Result(property = "optionC", column = "option_c"),
            @Result(property = "optionD", column = "option_d"),
            @Result(property = "optionE", column = "option_e")
    })
    @Select("select * from question")
    List<Question> findAll();


    @Select("select * from question where id = #{id}")
    Question getById(Integer id);

}
